package 递增三元组;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int N = 100010;
    static int[] A = new int[N];
    static int[] B = new int[N];
    static int[] C = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            A[i] = in.nextInt();
        }
        for (int i = 0; i < n; i++) {
            B[i] = in.nextInt();
        }
        for (int i = 0; i < n; i++) {
            C[i] = in.nextInt();
        }
        Arrays.sort(A, 0, n);
        Arrays.sort(B, 0, n);
        Arrays.sort(C, 0, n);
        long res = 0;
        int j = 0, k = 0;
        for (int i = 0; i < n; i++) {
            while (j < n && A[j] < B[i]) {
                j++;
            }
            while (k < n && C[k] <= B[i]) {
                k++;
            }
            res += (long) j * (n - k);
        }
        System.out.println(res);
    }
}
